#include "FindPattern.h"

bool FindPattern::bDataCompare(const BYTE* Buffer, const BYTE* Mask1, const char* Mask2)
{
	for(;*Mask2;++Mask2,++Buffer,++Mask1)
	{
		if(*Mask2=='x' && *Buffer!=*Mask1 )
		{
			return false;
		}
	}
	return true;
}

DWORD FindPattern::Find(DWORD Address, DWORD Length, const BYTE* Mask1, const char* Mask2)
{
	for(DWORD i = 0; i < Length; i++)
	{
		if(bDataCompare((BYTE*)(Address+i), Mask1, Mask2))
		{
			return Address+i;
		}
	}
	return 0;
}